/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.myapp.struts.forms;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author sivakumar pabolu
 */
public class TriangleCalculatorForm extends org.apache.struts.action.ActionForm {

    // TODO static triangleOption values.
    // public static String triangleOption1 = "3sides";

    // indicates what kind of a triangle user will choose.
    private String triangleOption;

    // indicates what the button the user clicked.
    private String userAction;

    //TODO convert these int variable types to doubles.
    private int sideA;
    private int sideB;
    private int sideC;
    private int angleA;
    private int angleB;
    private int angleC;

    //TODO need to convert this to a double. 
    private String result;

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public int getAngleA() {
        return angleA;
    }

    public void setAngleA(int angleA) {
        this.angleA = angleA;
    }

    public int getAngleB() {
        return angleB;
    }

    public void setAngleB(int angleB) {
        this.angleB = angleB;
    }

    public int getAngleC() {
        return angleC;
    }

    public void setAngleC(int angleC) {
        this.angleC = angleC;
    }

    public int getSideA() {
        return sideA;
    }

    public void setSideA(int sideA) {
        this.sideA = sideA;
    }

    public int getSideB() {
        return sideB;
    }

    public void setSideB(int sideB) {
        this.sideB = sideB;
    }

    public int getSideC() {
        return sideC;
    }

    public void setSideC(int sideC) {
        this.sideC = sideC;
    }

    public String getUserAction() {
        return userAction;
    }

    public void setUserAction(String userAction) {
        this.userAction = userAction;
    }

    public String getTriangleOption() {
        return triangleOption;
    }

    public void setTriangleOption(String triangleOption) {
        this.triangleOption = triangleOption;
    }
    
    /**
     *
     */
    public TriangleCalculatorForm() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (getTriangleOption() == null ) {
            errors.add("triangleOption", new ActionMessage("error.triangleOption.required"));
            // TODO: add 'error.name.required' key to your resources
        }
        return errors;
    }
}
